#[derive(Debug)]    // 派生Debug trait，用于后面使用调试格式打印Rectangle实例
struct Rectangle {
    width: u32,
    height: u32,
}

fn main() {
    let rect1 = Rectangle {
        width: 30,
        height: 50,
    };

    // println!("rect1 is {}", rect1); // 报错
    println!("rect1 is {:?}", rect1);   // 使用调试格式打印Rectangle实例
    println!("rect1 is {:#?}", rect1);   // 使用调试格式打印Rectangle实例

    println!(
        "The area of the rectangle is {} square pixels,",
        area(&rect1)
    );
}

fn area(rectangle: &Rectangle) -> u32 {
    rectangle.width * rectangle.height
}
